package edu.dayu.controller;

import com.github.pagehelper.PageInfo;
import edu.dayu.pojo.Activity;
import edu.dayu.pojo.Article;
import edu.dayu.service.ActivityService;
import edu.dayu.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/admin")
public class ActivityController {
    @Autowired
    private ActivityService activityService;

    @PostMapping("/activityList")
    public PageInfo<Activity> activityList(Activity activity){
        return activityService.activityList(activity);
    }

    @PostMapping("/activityInsert")
    public void activityInsert(Activity activity){
        activityService.activityInsert(activity);
    }

    @PostMapping("/activityUpdate")
    public void activityUpdate(Activity activity){
        activityService.activityUpdate(activity);
    }

    @PostMapping("activityDelete")
    public void activityDelete(Activity activity){
        activityService.activityDelete(activity);
    }

    @PostMapping("/activityById")
    public Activity activityById(Activity activity){
        List<Activity> activityList = activityService.activityList(activity).getList();
        Activity activity1 = new Activity();
        for (Activity activity2 : activityList) {
            activity1 = activity2;
        }
        return activity1;
    }
}
